<template>
  <div class="header">
    <div class="content-wrapper">
      <div class="avatar">
        <img :src="seller.avatar" alt="">
      </div>
      <div class="content">
        <div class="title">
          <span class="brand"></span>
          <span class="name">{{seller.name}}</span>
        </div>
        <div class="description">
          {{seller.description}}
          /
          {{seller.deliveryTime}}分钟送达
        </div>
        <div v-if="seller.supports" class="support">
          <support-ico class="icon" :size="1" :type="seller.supports[0].type"></support-ico>
          <span class="text">{{seller.supports[0].description}}</span>
        </div>
      </div>
      <div v-if="seller.supports" class="support-count" @click="showDatail()">
        <span class="count">{{seller.supports.length}}个</span>
        <i class="icon-keyboard_arrow_right"></i>
      </div>
    </div>
    <div class="bulletin-wrapper" @click="showDatail()">
      <span class="bulletin-title"></span>
      <span class="bulletin-text">{{seller.bulletin}}</span>
      <i class="icon-keyboard_arrow_right"></i>
    </div>
    <div class="background">
      <img :src="seller.avatar" width="100%" height="100%">
    </div>
    <transition name="detail-fade">
      <div v-show="detailShow" class="detail">
        <div class="detail-wrapper clearfix">
          <div class="detail-main">
            <h1 class="name">{{seller.name}}</h1>
            <div class="star-wrapper">
              <star :size="48" :score="seller.score"></star>
              <!-- 在外部包起来修改位置，定义好的组件不要乱动 -->
            </div>
            <detail-title class="detail-title" :titletext="'优惠信息'"></detail-title>
            <ul v-if="seller.supports" class="supports">
              <li class="suppor-item" v-for="item in seller.supports" :key="item.type">
                <support-ico class="icon" :size="2" :type="item.type"></support-ico>
                <span class="text">{{item.description}}</span>
              </li>
            </ul>
            <detail-title class="detail-title" :titletext="'商家公告'"></detail-title>
            <div class="bulletin">
              <p class="content">{{seller.bulletin}}</p>
            </div>
          </div>
        </div>
        <div class="detail-close">
          <i class="icon-close" @click="hideDatail()"></i>
        </div>
      </div>
    </transition>
  </div>
</template>

<script>
import star from '../star/star'
import detailTitle from '../detail-title/detail-title'
import supportIco from '../support-ico/support-ico'

export default {
  name: 'v-header',
  props: {
    seller: {
      type: Object,
      default() {
        return {}
      }
    }
  },
  data() {
    return {
      detailShow: false
    }
  },
  methods: {
    showDatail() {
      this.detailShow = true
    },
    hideDatail() {
      this.detailShow = false
    }
  },
  components: {
    star,
    'detail-title': detailTitle,
    'support-ico': supportIco
  }
}

</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style lang='stylus' scoped>
  @import "~common/stylus/mixin.styl"
  @import "~common/stylus/variable.styl"

  .header
    position: relative
    overflow: hidden
    color: #fff
    background-color: $color-background-ss
    .content-wrapper
      position: relative
      padding: 24px 12px 18px 24px
      font-size: 0
      .avatar
        display: inline-block
        vertical-align: top
        img
          width: 64px
          height: 64px
          border-radius: 2px
      .content
        display: inline-block
        margin-left: 16px
        .title
          margin 2px 0 8px 0
          .brand
            display: inline-block
            vertical-align: top
            width: 30px
            height: 18px
            bg-image('brand')
            background-size: 30px 18px
            background-repeat: no-repeat
          .name
            margin-left: 6px
            line-height: 18px
            font-size: $fontsize-large
            font-weight: bold
        .description
          margin-top: 8px
          margin-bottom: 10px
          line-height: 12px
          font-size: $fontsize-small
        .support
          .icon
            margin-right: 4px
          .text
            line-height 12px
            font-size: $fontsize-small-s
      .support-count
        position: absolute
        right: 12px
        bottom: 14px
        padding: 0px 8px
        height: 24px
        line-height: 24px
        text-align: center
        border-radius: 12px
        background-color: rgba(0,0,0,0.2)
        .count
          margin-right: 2px
          font-size: $fontsize-small-s
        .icon-keyboard_arrow_right
          line-height: 24px
          font-size: $fontsize-small-s
    .bulletin-wrapper
      position: relative
      height: 28px
      line-height: 28px
      padding: 0 22px 0 12px
      white-space: nowrap
      overflow: hidden
      text-overflow: ellipsis
      transition: all 0.5s linear
      background-color: $color-background-sss
      .bulletin-title
        margin-top 8px
        display: inline-block
        vertical-align: top
        width: 22px
        height: 12px
        bg-image('bulletin')
        background-size: 22px 12px
        background-repeat: no-reapeat
      .bulletin-text
        margin: 0 4px
        vertical-align: top
        font-size: $fontsize-small-s
      .icon-keyboard_arrow_right
        position: absolute
        right: 12px
        top: 8px
        font-size: $fontsize-small-s
    .background
      position: absolute
      top: 0
      left: 0
      width: 100%
      height: 100%
      z-index: -1
      filter: blur(10px)
    .detail-fade-enter-active, .detail-fade-leave-active {
      transition: opacity .5s;
      opacity: 1
    }
    .detail-fade-enter, .detail-fade-leave-to {
      opacity: 0
    }
    .detail
      position: fixed
      top: 0
      left: 0
      z-index: 100
      width: 100%
      height: 100%
      overflow: auto
      background-color: $color-background-s
      backdrop-filter: blur(5px)
      .detail-wrapper
        width: 100%
        min-height: 100%
        .detail-main
          margin-top: 64px
          padding-bottom: 64px
          .name
            line-height: 16px
            text-align: center
            font-size: $fontsize-large
            font-weight: 700
          .star-wrapper
            margin-top: 18px
            padding: 2px 0
            text-align: center
          .detail-title
            width: 80%
            margin: 28px auto 24px auto
          .supports
            width: 80%
            margin: 0 auto
            .suppor-item
              padding: 0 12px
              margin-bottom: 12px
              font-size: 0
              &:last-child
                margin-bottom: 0
              .icon
                margin-right: 6px
              .text
                line-height 16px
                font-size: $fontsize-small
                font-weight: 200
          .bulletin
            width: 80%
            margin: 0 auto
            .content
              padding: 0 12px
              line-height: 24px
              font-size: $fontsize-small
      .detail-close
        position: relative
        width: 32px
        height: 32px
        margin: -64px auto 0 auto
        clear: both
        font-size: 32px
</style>
